<script setup>
  import Button from '@/components/Button.vue'
  import { PROVIDE_KEY } from '../../consts.js'
  import { inject } from 'vue'

  const props = defineProps({
    file: Object,
    node: Object,
    requirement: Object,
  })

  let hasTemplate = false
  if (!props.file) {
    if (props.requirement.has_template) {
      hasTemplate = true
    }
  }

  const { onTemplate } = inject(PROVIDE_KEY)
</script>
<template>
  <td class="col_actions width_one">
    <Button
      v-if="hasTemplate"
      title="Générer le fichier depuis le modèle"
      @click="() => onTemplate(node, requirement, node.id)"
      icon="file-redo"
    />
  </td>
</template>
